package com.example.administrator.ygddriver.listen;

import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.administrator.ygddriver.R;

import java.util.List;

public class ListenAdapter extends BaseQuickAdapter<ListenRequestBean.ResultBean, BaseViewHolder> {
    public ListenAdapter(int layoutResId, @Nullable List<ListenRequestBean.ResultBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ListenRequestBean.ResultBean item) {
        helper.setText(R.id.item_fragment_listen_waybill_number_tv, item.getC_waybillnumber() + "个运单");
        helper.setText(R.id.item_fragment_listen_parcel_number_tv, "共" + item.getC_parcelnumber() + "件");
        helper.setText(R.id.item_fragment_listen_distance_tv, "总里程" + item.getC_distance() + "公里");
        helper.setText(R.id.item_fragment_listen_network_location_tv, item.getC_networklocation());
        helper.setText(R.id.item_fragment_listen_address_tv, item.getC_address());
        helper.setText(R.id.item_fragment_listen_money_tv, item.getC_freight() + "元");
        if (item.getC_isbargaining().equals("1")) {
            helper.setText(R.id.item_fragment_listen_is_bargaining_tv, "不可" + "\n" + "议价");
        } else if (item.getC_isbargaining().equals("2")) {
            helper.setText(R.id.item_fragment_listen_is_bargaining_tv, "可议价");
        }
        if (item.getC_status().equals("1")) {
            helper.setText(R.id.item_fragment_listen_rob_tv, "抢单");
            helper.addOnClickListener(R.id.item_fragment_listen_rob_tv);
        } else if (item.getC_status().equals("2")) {
            helper.setText(R.id.item_fragment_listen_rob_tv, "申请中");
        } else if (item.getC_status().equals("3")) {
            helper.setText(R.id.item_fragment_listen_rob_tv, "抢单" + "\n" + "失败");
        } else if (item.getC_status().equals("4")) {
            helper.setText(R.id.item_fragment_listen_rob_tv, "申请" + "\n" + "成功");
        }


    }
}
